
import axios from "axios"
export default ({
    namespaced:true,
  state: {
      articalData:[],
      searchType:'artical_title',
      searchValue:'',
      currentPage:1,
      pageSize:3,
      pages:''
  },
  mutations: {
      getArtical(state,payload){
        state.articalData = payload.articalData;
        state.pages = payload.pages;
      },
      search_artical(state,payload){
        state.searchValue = payload
      },
      changeCurrenPage(state,payload){
        state.currentPage = payload;
      }
  },
  actions: {
      getArticalAsync(context){
          const{searchType,searchValue,currentPage,pageSize} = context.state;
          axios
          .get('/artical/get',{params:{searchType,searchValue,currentPage,pageSize}})
          .then(res =>{
            context.commit('getArtical',res.data)
          })
      }
  },
})